package top.blueShark.template.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import top.blueShark.template.service.SysUserService;

import java.util.HashMap;
import java.util.Map;

@RestController
public class DashboardAnalysisController {

    @Autowired
    private SysUserService sysUserService;


    @GetMapping("/api/dashboard/analysis/overview")
    public Map<String, Object> getOverview() {
        // 1. 组装业务数据
        Map<String, Object> data = new HashMap<>();
        long userCount = sysUserService.getTotalUserCount(); // 从数据库查询用户总量
        int visitCount = 67890;  // 访问量（请替换为真实统计）
        int usageCount = 0; // 从数据库查询API总调用次数
        data.put("userCount", userCount);
        data.put("visitCount", visitCount);
        data.put("usageCount", usageCount);

        // 2. 组装标准返回结构
        Map<String, Object> result = new HashMap<>();
        result.put("code", 0);
        result.put("data", data);
        result.put("error", null);
        result.put("message", "ok");
        return result;
    }
}
